package com.example.demo.dao;

import com.example.demo.pojo.YYQX;
import com.example.demo.pojo.fans;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@Controller
public class FansDao {
    private static Map<Integer, fans> fans=null;
    @Autowired 
    private YYQXDao yyqxDao;
    static {
        fans=new HashMap<Integer,fans>();
        fans.put(01,new fans(01,"onlyLove1",18,0,new YYQX(1,"dance")));
        fans.put(02,new fans(02,"onlyLove2",21,1,new YYQX(2,"hulusi")));
        fans.put(03,new fans(03,"onlyLove3",28,1,new YYQX(3,"movie")));
        fans.put(04,new fans(04,"onlyLove4",15,1,new YYQX(4,"sing")));
    }
   //主键自增
    private static Integer initID=05;
    //增加一个员工
    public void save(fans fan){
        if(fan.getFansId()==null){
            fan.setFansId(initID++);
        }
        //fan.setYyqx(yyqxDao.getYyqxhobbysByfansID(fan.getFansId()));
        fans.put(fan.getFansId(),fan);
    }
    public Collection<fans>getAll(){
        return fans.values();
    }
    public fans getfansById(Integer id){
        return fans.get(id);
    }
    public void delete(Integer id){
        fans.remove(id);
    }

}
